Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

link-check

Package Overview
Dependencies
Maintainers
1
Versions
41
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

link-check

checks whether a hyperlink is alive (200 OK) or dead

  • 2.1.0
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
63K
decreased by-21.4%
Maintainers
1
Weekly downloads
 
Created
Source

Checks whether a hyperlink is alive (200 OK) or dead.

Installation

npm install --save link-check

Specification

A link is said to be 'alive' if an HTTP HEAD or HTTP GET for the given URL eventually ends in a 200 OK response. To minimize bandwidth, an HTTP HEAD is performed. If that fails (e.g. with a 405 Method Not Allowed), an HTTP GET is performed. Redirects are followed.

API

Given a link and a callback, attempt an HTTP HEAD and possibly an HTTP GET.

Parameters:

  • url string containing a URL.
  • opts optional options object containing any of the following optional fields:
  • baseUrl the base URL for relative links.
  • callback function which accepts (err, result).
  • err an Error object when the operation cannot be completed, otherwise null.
  • result an object with the following properties:
  • link the link provided as input
  • status a string set to either alive or dead.
  • statusCode the HTTP status code. Set to 0 if no HTTP status code was returned (e.g. when the server is down).
  • err any connection error that occurred, otherwise null.

Examples

'use strict';

var linkCheck = require('link-check');

linkCheck('http://example.com', function (err, result) {
    if (err) {
        console.error('Error', err);
        return;
    }
    console.log('%s is %s', result.link, result.status);
});

Testing

npm test

License

See LICENSE.md

Keywords

FAQs

Package last updated on 07 Jul 2016

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc